import { axios } from '@/utils/request'
// 获取用户分页数据
function getStrategyPageData (query, versionType, upgradeTriggerType) {
  return axios({
    url: '/task-service/strategy/list/' + versionType.toLowerCase(),
    method: 'get',
    params: query
  })
}

// 添加条件/升级策略数据
function addStrategyData (data, versionType, upgradeTriggerType) {
  return axios({
    url: '/task-service/strategy/' + versionType.toLowerCase(),
    method: 'post',
    data
  })
}

// 编辑条件/升级策略数据
function editStrategyData (data, versionType, upgradeTriggerType) {
  return axios({
    url: '/task-service/strategy/' + versionType.toLowerCase(),
    method: 'put',
    data
  })
}

// 删除策略数据
function deleteStrategyData (ids, versionType, upgradeTriggerType) {
  return axios({
    url: '/task-service/strategy/' + versionType.toLowerCase(),
    method: 'delete',
    data: {
      ids
    }
  })
}

// 获取所有条件策略数据
function getStrategyAllData (params, versionType, upgradeTriggerType) {
  return axios({
    url: '/task-service/strategy/select/' + versionType.toLowerCase(),
    method: 'get',
    params
  })
}

// 获取某策略的详情
function getStrategyDetailById (id) {
  return axios({
    url: '/task-service/strategy/info',
    method: 'get',
    params: {
      id
    }
  })
}
// 获取任务条件策略项
function getTaskConditionById (id) {
  return axios({
    url: '/task-service/task/condition',
    method: 'get',
    params: {
      id
    }
  })
}
// 策略创建人下拉框数据
function getCreateStrategyUsers (params, versionType, upgradeTriggerType) {
  return axios({
    url: '/task-service/strategy/select/createBy/' + versionType.toLowerCase(),
    method: 'get',
    params
  })
}
// 发布策略
function publishStrategy (data, versionType, upgradeTriggerType) {
  return axios({
    url: '/task-service/strategy/publish/' + versionType.toLowerCase(),
    method: 'put',
    data
  })
}

// 停用策略
function disabledStrategy (data, versionType, upgradeTriggerType) {
  return axios({
    url: '/task-service/strategy/enable/' + versionType.toLowerCase(),
    method: 'put',
    data
  })
}

// 添加sota条件/升级策略
function addSotaStrategy (data) {
  return axios({
    url: '/task-service/strategy/sota',
    method: 'post',
    data
  })
}

// 编辑sota条件/升级策略
function editSotaStrategy (data) {
  return axios({
    url: '/task-service/strategy/sota',
    method: 'put',
    data
  })
}
export default {
  getStrategyPageData:getStrategyPageData,
  addStrategyData:addStrategyData,
  editStrategyData:editStrategyData,
  getStrategyAllData:getStrategyAllData,
  getStrategyDetailById:getStrategyDetailById,
  getTaskConditionById:getTaskConditionById,
  deleteStrategyData:deleteStrategyData,
  getCreateStrategyUsers:getCreateStrategyUsers,
  publishStrategy:publishStrategy,
  disabledStrategy:disabledStrategy,
  addSotaStrategy,
  editSotaStrategy
}
